
#include <stddef.h>
#include <stdlib.h>
#include "enemies.h"
#include "groupController.h"
#include "debris.h"

float levelPosition;


void worldLoad(char *levelName)
{
	Enemy *enemy = enemyGetNew(ENEMY_TYPE_TURRET);
	enemy->x = 101.0f;
	enemy->y = 102.0f;
	
	enemy = enemyGetNew(ENEMY_TYPE_TURRET);
	enemy->x = 401.0f;
	enemy->y = 102.0f;
	enemy->gunDirection = 30.0f;
	enemy->currentMode = ENEMY_MODE_TURRET_DIRECTSHOOT;
}

void worldDraw()
{
	enemiesDrawUpdate();
	groupUpdate();
	debrisDrawUpdate();
}

void worldAdvance(float step)
{
	Enemy *enemy;
	
	if(rand()%200==1)
	{
		enemy = enemyGetNew(ENEMY_TYPE_TURRET);
		enemy->x = rand()%680;
		enemy->y = -20.0f;
		enemy->currentMode = ENEMY_MODE_TURRET_DIRECTSHOOT;
	}
	if(rand()%200==1)
	{
		enemy = enemyGetNew(ENEMY_TYPE_STRIKER);
		enemy->x = rand()%680;
		enemy->y = -20.0f;
		enemy->heading = rand()%360;
		enemy->currentMode = ENEMY_MODE_NORMAL;
	}
	if(rand()%500==1)
	{
		groupCreate(ENEMY_TYPE_STRIKER);
	}
	
	enemy = enemies_enabled_head;
	
	while(enemy!=NULL)
	{
		enemy->y += step;
	  	enemy = enemy->next;
	}
}
